﻿using System;
using System.Diagnostics;
using Internal.UIOC;
using UIOC.Attributes;

namespace UIOC.Observable {

    public interface IObservableModel : IObservableObject {
    }

    public interface IModel : IObject, IObservableModel {
    }

#if !DISABLE_DEBUGGER_ATTRIBUTE
    [DebuggerStepThrough]
    [DebuggerNonUserCode]
#endif
    [SkipInternalValidation]
    public abstract partial class Model : Object, IModel, IPooledObjectInternal {

        [Internal]
        [Obsolete]
#if !DISABLE_DEBUGGER_ATTRIBUTE
        [DebuggerHidden]
#endif
        protected virtual void Internal__Model_Allocate__() { }
#if !DISABLE_DEBUGGER_ATTRIBUTE
        [DebuggerHidden]
#endif
        void IPooledObjectInternal.Allocate() {
            if (this is IAutowiredInternal autowired) {
                autowired.Allocate();
            }
            Allocate();
#pragma warning disable CS0612 // 类型或成员已过时
            Internal__Model_Allocate__();
#pragma warning restore CS0612 // 类型或成员已过时
        }

        [Internal]
        [Obsolete]
#if !DISABLE_DEBUGGER_ATTRIBUTE
        [DebuggerHidden]
#endif
        protected virtual void Internal__Model_Release__() { }
#if !DISABLE_DEBUGGER_ATTRIBUTE
        [DebuggerHidden]
#endif
        void IPooledObjectInternal.Release() {
#pragma warning disable CS0612 // 类型或成员已过时
            Internal__Model_Release__();
#pragma warning restore CS0612 // 类型或成员已过时
            if (this is IAutowiredInternal autowired) {
                autowired.Release();
            }
            Release();
        }
    }
}

namespace Internal.UIOC.Observable {

    //public interface IModelInternal {

    //    void Allocate();
    //}
}
